home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15550 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: bbs.ug.eds.com!berryb
  2. Newsgroups: comp.lang.c
  3. Subject: Pointer to read file...
  4. Message-ID: <1996Apr19.110223@bbs.ug.eds.com>
  5. From: berryb@bbs.ug.eds.com (High Plains GRIPster (TRW C.S.D.))
  6. Date: 19 Apr 96 11:02:23 PDT
  7. Organization: TRW C.S.D.
  8. Nntp-Posting-Host: bbs
  9.  
  10. 4/19/96
  11.  
  12. I have a beginners C question.
  13. After going page by page through my Learning C book,
  14. I am still in a quandry.
  15.  
  16. I have a pointer to a file:    FILE *fp;
  17.  
  18. I have a pointer to a pointer:    FILE **p2f = &fp;
  19.  
  20. I have a character pointer:    char*fname="/user2/bcb/grip/unix/c/listing";
  21.  
  22. After I open my file...        if ( (fp = fopen (file1, "r")) != NULL)
  23.  
  24. I want to be able to use the p2f pointer, which is pointing at
  25. the beginning of the file, to read the character that it is
  26. pointing at...and then move to the next character and read
  27. that character until EOF is reached.
  28.  
  29. I am able to increment the pointers position by  p2f++;
  30. but I am unable to read the character.  This is probably
  31. because I need a character pointer to read a character,
  32. and the FILE pointer just cant perform that way.
  33.  
  34. If I try to use this line:    char **p2f = &fp;
  35. it errors on compilation saying types FILE* and char*
  36. are incompatible as used.  I thought about using a 
  37. void pointer and casting it to a character pointer?
  38.  
  39. I wish I had more experience at this.
  40.  
  41. brett
  42.  
  43.